home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / lang / sofa.lha / sofa / smalleiffel / lib_se / native_small_eiffel.e < prev    next >
Text File  |  2000-03-25  |  74KB  |  2,138 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr
  4. --                       http://SmallEiffel.loria.fr
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License
  11. -- for  more  details.  You  should  have  received a copy of the GNU General
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class NATIVE_SMALL_EIFFEL
  17.  
  18. inherit NATIVE;
  19.  
  20. creation make
  21.  
  22. feature
  23.  
  24.    need_prototype: BOOLEAN is false;
  25.  
  26.    stupid_switch_function(r: ARRAY[RUN_CLASS]; name: STRING): BOOLEAN is
  27.       do
  28.          if as_character_bits = name or else
  29.             as_generating_type = name or else 
  30.             as_generator = name or else 
  31.             as_to_pointer = name or else
  32.             as_stdout = name
  33.           then
  34.             Result := true;
  35.          end;
  36.       end;
  37.  
  38.    stupid_switch_procedure(r: ARRAY[RUN_CLASS]; name: STRING): BOOLEAN is
  39.       do
  40.          if as_write_byte = name then
  41.             Result := true;
  42.          end;
  43.       end;
  44.  
  45.    c_define_procedure(rf7: RUN_FEATURE_7; bcn, name: STRING) is
  46.       do
  47.          if as_bit_n = bcn then
  48.             c_define_procedure_bit(rf7,name);
  49.          end;
  50.       end;
  51.  
  52.    c_mapping_procedure(rf7: RUN_FEATURE_7; bcn, name: STRING) is
  53.       local
  54.          t: TYPE;
  55.       do
  56.          if as_copy = name or else as_standard_copy = name then
  57.             t := rf7.current_type;
  58.             if t.is_reference then
  59.                cpp.put_string("*((T");
  60.                cpp.put_integer(t.id);
  61.                cpp.put_string("*)(");
  62.                cpp.put_target_as_value;
  63.                cpp.put_string("))=*((T");
  64.                cpp.put_integer(t.id);
  65.                cpp.put_string("*)(");
  66.                cpp.put_ith_argument(1);
  67.                cpp.put_string(fz_16);
  68.             elseif t.is_basic_eiffel_expanded then
  69.                cpp.put_target_as_value;
  70.                cpp.put_string(fz_00);
  71.                cpp.put_ith_argument(1);
  72.                cpp.put_string(fz_00);
  73.             else
  74.                cpp.put_string("{void* d=");
  75.                cpp.put_target_as_target;
  76.                cpp.put_string(";%NT");
  77.                cpp.put_integer(t.id);
  78.                cpp.put_string(" s;%Ns=(");
  79.                cpp.put_ith_argument(1);
  80.                cpp.put_string(");%Nmemcpy(d,&s,sizeof(s));}%N");
  81.             end;
  82.          elseif as_flush_stream = name then
  83.             if cpp.target_cannot_be_dropped then
  84.                cpp.put_string(fz_14);
  85.             end;
  86.             cpp.put_string("fflush(");
  87.             cpp.put_ith_argument(1);
  88.             cpp.put_string(fz_14);
  89.          elseif as_write_byte = name then
  90.             cpp.put_string("putc(");
  91.             cpp.put_ith_argument(2);
  92.             cpp.put_string(",((FILE*)(");
  93.             cpp.put_ith_argument(1);
  94.             cpp.put_string(")));%N");
  95.          elseif as_print_run_time_stack = name then
  96.             cpp.put_string("se_print_run_time_stack();%N");
  97.          elseif as_die_with_code = name then
  98.             if cpp.target_cannot_be_dropped then
  99.                cpp.put_string(fz_14);
  100.             end;
  101.             cpp.put_string("exit(");
  102.             cpp.put_ith_argument(1);
  103.             cpp.put_string(fz_14);
  104.          elseif as_se_system = name then
  105.             cpp.put_string("system(((char*)");
  106.             cpp.put_ith_argument(1);
  107.             cpp.put_string(fz_16);
  108.          elseif as_c_inline_c = name then
  109.             cpp.put_c_inline_c;
  110.          elseif as_c_inline_h = name then
  111.             cpp.put_c_inline_h;
  112.          elseif as_trace_switch = name then
  113.             cpp.put_trace_switch;
  114.          elseif as_native_array = bcn then
  115.             c_mapping_native_array_procedure(rf7,name);
  116.          elseif as_bit_n = bcn then
  117.             c_mapping_bit_procedure(rf7,name);
  118.          elseif as_sprintf_pointer = name then
  119.             cpp.put_string("{void*p=");
  120.             cpp.put_target_as_value;
  121.             cpp.put_string(";%Nsprintf((");
  122.             cpp.put_ith_argument(1);
  123.             cpp.put_string("),%"%%p%",p);}%N");
  124.          elseif as_sprintf_double = name then
  125.             cpp.put_string("{/*sprintf_double*/%N%
  126.                            %char fmt[32];%N%
  127.                            %double d=");
  128.             cpp.put_target_as_value;
  129.             cpp.put_string(";%N%
  130.                            %fmt[0]='%%';%N%
  131.                            %fmt[1]='.';%N%
  132.                            %sprintf(fmt+2,%"%%df\0%",(");
  133.             cpp.put_ith_argument(2);
  134.             cpp.put_string("));%Nsprintf(((char*)(");
  135.             cpp.put_ith_argument(1);
  136.             cpp.put_string(")),fmt,d);%N}%N");
  137.          elseif as_se_rename = name then
  138.             cpp.put_string("rename(((char*)");
  139.             cpp.put_ith_argument(1);
  140.             cpp.put_string("),((char*)");
  141.             cpp.put_ith_argument(2);
  142.             cpp.put_string(fz_16);
  143.          elseif as_se_remove = name then
  144.             cpp.put_string("remove(((char*)");
  145.             cpp.put_ith_argument(1);
  146.             cpp.put_string(fz_16);
  147.          elseif as_raise_exception = name then
  148.             cpp.put_string("internal_exception_handler(");
  149.             cpp.put_ith_argument(1);
  150.             cpp.put_string(fz_14);
  151.          end;
  152.       end;
  153.  
  154.    c_define_function(rf8: RUN_FEATURE_8; bcn, name: STRING) is
  155.       local
  156.          elt_type: TYPE;
  157.          ct: TYPE;
  158.          rc: RUN_CLASS;
  159.          rf: RUN_FEATURE;
  160.          rf7: RUN_FEATURE_7;
  161.       do
  162.          if as_bit_n = bcn then
  163.             c_define_function_bit(rf8,name);
  164.          elseif as_general = bcn then
  165.             if as_is_equal = name or else as_standard_is_equal = name then
  166.                ct := rf8.current_type;
  167.                rc := ct.run_class;
  168.                if ct.is_basic_eiffel_expanded then
  169.                elseif ct.is_native_array then
  170.                elseif ct.is_bit then
  171.                elseif rc.is_tagged then
  172.                   rf8.c_define_with_body(
  173.                      "R=((C->id==a1->id)?!memcmp(C,a1,sizeof(*C)):0);");
  174.                elseif rc.writable_attributes = Void then
  175.                   if run_control.boost then
  176.                   else
  177.                      rf8.c_define_with_body("R=1;");
  178.                   end;
  179.                elseif run_control.boost then
  180.                else
  181.                   rf8.c_define_with_body("R=!memcmp(C,&a1,sizeof(*C));");
  182.                end;
  183.             elseif as_standard_twin = name then
  184.                c_define_standard_twin(rf8,rf8.current_type);
  185.             elseif as_twin = name then
  186.                ct := rf8.current_type;
  187.                rc := ct.run_class;
  188.                rf := rc.get_copy;
  189.                rf7 ?= rf;
  190.                if rf7 /= Void then
  191.                   c_define_standard_twin(rf8,ct);
  192.                else
  193.                   c_define_twin(rf8,ct,rc,rf);
  194.                end;
  195.             elseif as_deep_twin = name then
  196.                ct := rf8.current_type;
  197.            if ct.is_basic_eiffel_expanded then
  198.           rf8.c_define_with_body("R=C;%N");
  199.            elseif ct.is_native_array then
  200.           eh.add_type(ct,fz_dtideena);
  201.           eh.print_as_fatal_error;
  202.            else
  203.           body.clear;
  204.           ct.run_class.deep_twin_in(body);
  205.           rf8.c_define_with_body(body);
  206.            end;
  207.             elseif as_is_deep_equal = name then
  208.                ct := rf8.current_type;
  209.            if ct.is_basic_eiffel_expanded then
  210.           rf8.c_define_with_body("R=(C==a1);%N");
  211.            elseif ct.is_native_array then
  212.           eh.add_type(ct,fz_dtideena);
  213.           eh.print_as_fatal_error;
  214.            else
  215.           body.clear;
  216.           ct.run_class.is_deep_equal_in(body);
  217.           rf8.c_define_with_body(body);
  218.            end;
  219.             end;
  220.          elseif as_native_array = bcn then
  221.             if as_calloc = name then
  222.                ct := rf8.current_type;
  223.                elt_type := ct.generic_list.item(1).run_type;
  224.                if elt_type.expanded_initializer /= Void then
  225.                   body.clear;
  226.                   body.append("R=");
  227.                   if gc_handler.is_off then
  228.                      body.append("malloc(sizeof(T");
  229.                      elt_type.id.append_in(body);
  230.                      body.append(")*");
  231.                   else
  232.                      body.append("(void*)new");
  233.                      ct.id.append_in(body);
  234.                      body.extend('(');
  235.                   end;
  236.                   body.append("a1);%Nr");
  237.                   ct.id.append_in(body);
  238.                   body.append("clear_all(");
  239.                   if run_control.no_check then
  240.                      body.append("&ds,");
  241.                   end;
  242.                   body.append("R,a1-1);%N");
  243.                   rf8.c_define_with_body(body);
  244.                end;
  245.             end
  246.          end;
  247.       end;
  248.  
  249.    c_mapping_function(rf8: RUN_FEATURE_8; bcn, name: STRING) is
  250.       local
  251.          cbd: BOOLEAN;
  252.          ct: TYPE;
  253.          rc: RUN_CLASS;
  254.          rf: RUN_FEATURE;
  255.          rf7: RUN_FEATURE_7;
  256.          basic_eq: BOOLEAN;
  257.          type_bit: TYPE_BIT;
  258.       do
  259.          if as_stderr = name then
  260.             cpp.put_string(as_stderr);
  261.          elseif as_stdin = name then
  262.             cpp.put_string(as_stdin);
  263.          elseif as_stdout = name then
  264.             cpp.put_string(as_stdout);
  265.          elseif as_general = bcn then
  266.             if as_generating_type = name then
  267.                cpp.put_generating_type(rf8.current_type);
  268.             elseif as_generator = name then
  269.                cpp.put_generator(rf8.current_type);
  270.             elseif as_to_pointer = name then
  271.                cpp.put_to_pointer;
  272.             elseif as_object_size = name then
  273.                cpp.put_object_size(rf8.current_type);
  274.             elseif as_is_equal = name or else as_standard_is_equal = name then
  275.                ct := rf8.current_type;
  276.                rc := ct.run_class;
  277.                if ct.is_basic_eiffel_expanded then
  278.                   basic_eq := true;
  279.                elseif ct.is_native_array then
  280.                   basic_eq := true;
  281.                elseif ct.is_bit then
  282.                   type_bit ?= ct;
  283.                   basic_eq := not type_bit.is_c_unsigned_ptr;
  284.                end;
  285.                if basic_eq then
  286.                   cpp.put_character('(');
  287.                   cpp.put_target_as_value;
  288.                   cpp.put_character(')');
  289.                   cpp.put_string(fz_c_eq);
  290.                   cpp.put_character('(');
  291.                   cpp.put_ith_argument(1);
  292.                   cpp.put_character(')');
  293.                elseif rc.is_tagged then
  294.                   rf8.default_mapping_function;
  295.                elseif rc.writable_attributes = Void then
  296.                   if run_control.boost then
  297.                      cbd := cpp.cannot_drop_all;
  298.                      if cbd then
  299.                         cpp.put_character(',');
  300.                      end;
  301.                      cpp.put_character('1');
  302.                      if cbd then
  303.                         cpp.put_character(')');
  304.                      end;
  305.                   else
  306.                      rf8.default_mapping_function;
  307.                   end;
  308.                elseif run_control.boost then
  309.                   cpp.put_string("!memcmp(");
  310.                   cpp.put_target_as_target;
  311.                   cpp.put_character(',');
  312.                   if ct.is_user_expanded then
  313.                      cpp.put_character('&');
  314.                   end;
  315.                   cpp.put_character('(');
  316.                   cpp.put_ith_argument(1);
  317.                   cpp.put_string("),sizeof(T");
  318.                   cpp.put_integer(rc.id);
  319.                   cpp.put_string(fz_13);
  320.                else
  321.                   rf8.default_mapping_function;
  322.                end;
  323.             elseif as_standard_twin = name then
  324.                c_mapping_standard_twin(rf8,rf8.current_type);
  325.             elseif as_twin = name then
  326.                ct := rf8.current_type;
  327.                rc := ct.run_class;
  328.                rf := rc.get_copy;
  329.                rf7 ?= rf;
  330.                if rf7 /= Void then
  331.                   c_mapping_standard_twin(rf8,ct);
  332.                else
  333.                   rf8.default_mapping_function;
  334.                end;
  335.             elseif as_deep_twin = name then
  336.            ct := rf8.current_type;
  337.            if ct.is_basic_eiffel_expanded then
  338.                   cpp.put_target_as_target;
  339.            elseif ct.is_user_expanded then
  340.           rf8.default_mapping_function;
  341.            else
  342.           cpp.put_string("(se_deep_twin_start(),se_deep_twin_trats(");
  343.           rf8.default_mapping_function;
  344.           cpp.put_string("))");
  345.            end;
  346.             elseif as_is_deep_equal = name then
  347.            ct := rf8.current_type;
  348.            rf8.default_mapping_function;
  349.             elseif as_is_basic_expanded_type = name then
  350.                cbd := cpp.cannot_drop_all;
  351.                if cbd then
  352.                   cpp.put_character(',');
  353.                end;
  354.                if rf8.current_type.is_basic_eiffel_expanded then
  355.                   cpp.put_character('1');
  356.                else
  357.                   cpp.put_character('0');
  358.                end;
  359.                if cbd then
  360.                   cpp.put_character(')');
  361.                end;
  362.             elseif as_is_expanded_type = name then
  363.                cbd := cpp.cannot_drop_all;
  364.                if cbd then
  365.                   cpp.put_character(',');
  366.                end;
  367.                if rf8.current_type.is_expanded then
  368.                   cpp.put_character('1');
  369.                else
  370.                   cpp.put_character('0');
  371.                end;
  372.                if cbd then
  373.                   cpp.put_character(')');
  374.                end;
  375.             elseif as_se_argc = name then
  376.                cpp.put_string(as_se_argc);
  377.             elseif as_se_argv = name then
  378.                cpp.put_string("((T0*)se_string_from_external_copy(se_argv[_i]))");
  379.             elseif as_se_getenv = name then
  380.                cpp.put_string(
  381.                "(NULL==(_p=getenv((char*)_p)))?NULL:%
  382.                %((T0*)se_string_from_external_copy((char*)_p))");
  383.             end;
  384.          elseif as_native_array = bcn then
  385.             c_mapping_native_array_function(rf8,name);
  386.          elseif as_integer = bcn then
  387.             c_mapping_integer_function(rf8,name);
  388.          elseif as_real = bcn then
  389.             c_mapping_real_function(rf8,name);
  390.          elseif as_double = bcn then
  391.             c_mapping_double_function(rf8,name);
  392.          elseif as_boolean = bcn then
  393.             if as_implies = name then
  394.                cpp.put_string("(!(");
  395.                cpp.put_target_as_value;
  396.                cpp.put_string("))||(");
  397.                cpp.put_arguments;
  398.                cpp.put_character(')');
  399.             else
  400.                check
  401.                   rf8.arg_count = 1;
  402.                end;
  403.                cpp.put_character('(');
  404.                cpp.put_target_as_value;
  405.                if as_or_else = name then
  406.                   cpp.put_string(")||(");
  407.                else
  408.                   check
  409.                      as_and_then = name;
  410.                   end;
  411.                   cpp.put_string(")&&(");
  412.                end;
  413.                cpp.put_arguments;
  414.                cpp.put_character(')');
  415.             end;
  416.          elseif as_character = bcn then
  417.             cpp.put_string("T3");
  418.             cpp.put_string(name);
  419.             cpp.put_character('(');
  420.             cpp.put_target_as_value;
  421.             cpp.put_character(')');
  422.          elseif as_pointer = bcn then
  423.             check
  424.                as_is_not_null = name
  425.             end;
  426.             cpp.put_string("(NULL!=");
  427.             cpp.put_target_as_value;
  428.             cpp.put_character(')');
  429.          elseif as_platform = bcn then
  430.             cbd := cpp.target_cannot_be_dropped;
  431.             if cbd then
  432.                cpp.put_character(',');
  433.             end;
  434.             tmp_string.copy("EIF_");
  435.             tmp_string.append(name);
  436.             tmp_string.to_upper;
  437.             cpp.put_string(tmp_string);
  438.             if cbd then
  439.                cpp.put_character(')');
  440.             end;
  441.          elseif as_eof_code = name then
  442.             cbd := cpp.cannot_drop_all;
  443.             if cbd then
  444.                cpp.put_character(',');
  445.             end;
  446.             cpp.put_string("(EOF)");
  447.             if cbd then
  448.                cpp.put_character(')');
  449.             end;
  450.          elseif as_feof = name then
  451.             cpp.put_string("feof((FILE*)(");
  452.             cpp.put_ith_argument(1);
  453.             cpp.put_string(fz_13);
  454.          elseif as_sfr_open = name then
  455.             cpp.put_string("fopen((char*)");
  456.             cpp.put_ith_argument(1);
  457.             cpp.put_string(",%"r%")");
  458.          elseif as_sfw_open = name then
  459.             cpp.put_string("fopen((char*)");
  460.             cpp.put_ith_argument(1);
  461.             cpp.put_string(",%"w%")");
  462.          elseif as_se_string2double = name then
  463.             cpp.put_string("(sscanf(_p,%"%%lf%",&R),R)");
  464.          elseif as_bit_n = bcn then
  465.             c_mapping_bit_function(rf8,name);
  466. -- *** ???
  467. --         elseif as_item = name then
  468. --            cpp.put_character('(');
  469. --            cpp.put_target_as_value;
  470. --            cpp.put_string(")->_item");
  471. -- *** ???
  472.          elseif as_pointer_size = name then
  473.             cpp.put_string(fz_sizeof);
  474.             cpp.put_character('(');
  475.             cpp.put_string(fz_t0_star);
  476.             cpp.put_character(')');
  477.          elseif as_read_byte = name then
  478.             cpp.put_string("getc((FILE*)(");
  479.             cpp.put_ith_argument(1);
  480.             cpp.put_string(fz_13);
  481.          elseif as_exception = name then
  482.             cpp.put_string("internal_exception_number");
  483.          elseif as_signal_number = name then
  484.             cpp.put_string("signal_exception_number");
  485.          elseif name.has_prefix(fz_basic_) then
  486.             cpp.put_string(name);
  487.             cpp.put_character('(');
  488.             if rf8.arguments /= Void then
  489.                cpp.put_arguments;
  490.             end;
  491.             cpp.put_character(')');
  492.          end;
  493.       end;
  494.  
  495.    jvm_add_method_for_function(rf8: RUN_FEATURE_8; bcn, name: STRING) is
  496.       local
  497.          ct: TYPE;
  498.          rc: RUN_CLASS;
  499.          rf: RUN_FEATURE;
  500.          rf7: RUN_FEATURE_7;
  501.       do
  502.          if as_general = bcn then
  503.             if as_twin = name then
  504.                ct := rf8.current_type;
  505.                rc := ct.run_class;
  506.                rf := rc.get_copy;
  507.                rf7 ?= rf;
  508.                if rf7 /= Void then
  509.                else
  510.                   jvm.add_method(rf8);
  511.                end;
  512.             elseif as_generating_type = name then
  513.                jvm.add_method(rf8);
  514.             elseif as_generator = name then
  515.                jvm.add_method(rf8);
  516.             end;
  517.          end;
  518.       end;
  519.  
  520.    jvm_define_function(rf8: RUN_FEATURE_8; bcn, name: STRING) is
  521.       local
  522.          ct: TYPE;
  523.          rc: RUN_CLASS;
  524.          rf: RUN_FEATURE;
  525.          rf7: RUN_FEATURE_7;
  526.          rc_idx, field_idx, point1: INTEGER;
  527.          cp: like constant_pool;
  528.          ca: like code_attribute;
  529.       do
  530.          cp := constant_pool;
  531.          ca := code_attribute;
  532.          if as_general = bcn then
  533.             if as_twin = name then
  534.                ct := rf8.current_type;
  535.                rc := ct.run_class;
  536.                rf := rc.get_copy;
  537.                rf7 ?= rf;
  538.                if rf7 /= Void then
  539.                else
  540.                   jvm_define_twin(rf8,rc,rf);
  541.                end;
  542.             elseif as_generating_type = name then
  543.                rf8.jvm_opening;
  544.                ct := rf8.current_type;
  545.                rc := ct.run_class;
  546.                rc_idx := rc.jvm_constant_pool_index;
  547.                field_idx := cp.idx_fieldref_generating_type(rc_idx);
  548.                ca.opcode_getstatic(field_idx,1);
  549.                ca.opcode_dup;
  550.                point1 := ca.opcode_ifnonnull;
  551.                ca.opcode_pop;
  552.                ca.opcode_push_manifest_string(ct.run_time_mark);
  553.                ca.opcode_dup;
  554.                ca.opcode_putstatic(field_idx,-1);
  555.                ca.resolve_u2_branch(point1);
  556.                rf8.jvm_closing_fast;
  557.             elseif as_generator = name then
  558.                rf8.jvm_opening;
  559.                ct := rf8.current_type;
  560.                rc := ct.run_class;
  561.                rc_idx := rc.jvm_constant_pool_index;
  562.                field_idx := cp.idx_fieldref_generator(rc_idx);
  563.                ca.opcode_getstatic(field_idx,1);
  564.                ca.opcode_dup;
  565.                point1 := ca.opcode_ifnonnull;
  566.                ca.opcode_pop;
  567.                ca.opcode_push_manifest_string(ct.base_class_name.to_string);
  568.                ca.opcode_dup;
  569.                ca.opcode_putstatic(field_idx,-1);
  570.                ca.resolve_u2_branch(point1);
  571.                rf8.jvm_closing_fast;
  572.             end;
  573.          end;
  574.       end;
  575.  
  576.    jvm_mapping_function(rf8: RUN_FEATURE_8; bcn, name: STRING) is
  577.       local
  578.          ct: TYPE;
  579.          rc: RUN_CLASS;
  580.          rf: RUN_FEATURE;
  581.          rf7: RUN_FEATURE_7;
  582.          point1, point2, space, idx: INTEGER;
  583.          cp: like constant_pool;
  584.          ca: like code_attribute;
  585.       do
  586.          ca := code_attribute;
  587.          cp := constant_pool;
  588.          if as_to_pointer = name then
  589.             jvm.push_target;
  590.          elseif as_stdin = name then
  591.             ca.opcode_system_in;
  592.          elseif as_stdout = name then
  593.             ca.opcode_system_out;
  594.          elseif as_stderr = name then
  595.             ca.opcode_system_err;
  596.          elseif as_integer = bcn then
  597.             jvm_mapping_integer_function(rf8,name);
  598.          elseif as_real = bcn then
  599.             jvm_mapping_real_function(rf8,name);
  600.          elseif as_double = bcn then
  601.             jvm_mapping_double_function(rf8,name);
  602.          elseif as_native_array = bcn then
  603.             jvm_mapping_native_array_function(rf8,name);
  604.          elseif as_character = bcn then
  605.             if as_code = name then
  606.                jvm.push_target;
  607.                ca.opcode_dup;
  608.                point1 := ca.opcode_ifge;
  609.                ca.opcode_sipush(255);
  610.                ca.opcode_iand;
  611.                ca.resolve_u2_branch(point1);
  612.             elseif as_to_integer = name then
  613.                jvm.push_target;
  614.             else
  615.                check
  616.                   as_to_bit = name
  617.                end;
  618.                jvm_int_to_bit(rf8.result_type,8);
  619.             end;
  620.          elseif as_is_not_null = name then
  621.             jvm.push_target;
  622.             point1 := ca.opcode_ifnonnull;
  623.             ca.opcode_iconst_0;
  624.             point2 := ca.opcode_goto;
  625.             ca.resolve_u2_branch(point1);
  626.             ca.opcode_iconst_1;
  627.             ca.resolve_u2_branch(point2);
  628.          elseif as_implies = name then
  629.             jvm.push_target;
  630.             point1 := ca.opcode_ifeq;
  631.             space := jvm.push_ith_argument(1);
  632.             point2 := ca.opcode_goto;
  633.             ca.resolve_u2_branch(point1);
  634.             ca.opcode_iconst_1;
  635.             ca.resolve_u2_branch(point2);
  636.          elseif as_general = bcn then
  637.             if as_generating_type = name then
  638.                rf8.routine_mapping_jvm;
  639.             elseif as_generator = name then
  640.                rf8.routine_mapping_jvm;
  641.             elseif as_to_pointer = name then
  642.                fe_nyi(rf8);
  643.             elseif as_object_size = name then
  644.                jvm.drop_target;
  645.                ct := rf8.current_type;
  646.                jvm_object_size(ct);
  647.             elseif as_is_equal = name or else
  648.                as_standard_is_equal = name
  649.              then
  650.                jvm.push_target;
  651.                space := jvm.push_ith_argument(1);
  652.                rf8.current_type.jvm_standard_is_equal;
  653.             elseif as_standard_twin = name then
  654.                jvm_standard_twin(rf8.current_type);
  655.             elseif as_twin = name then
  656.                ct := rf8.current_type;
  657.                rc := ct.run_class;
  658.                rf := rc.get_copy;
  659.                rf7 ?= rf;
  660.                if rf7 /= Void then
  661.                   jvm_standard_twin(ct);
  662.                else
  663.                   rf8.routine_mapping_jvm;
  664.                end;
  665.             elseif as_is_basic_expanded_type = name then
  666.                jvm.drop_target;
  667.                if rf8.current_type.is_basic_eiffel_expanded then
  668.                   ca.opcode_iconst_1;
  669.                else
  670.                   ca.opcode_iconst_0;
  671.                end;
  672.             elseif as_is_expanded_type = name then
  673.                jvm.drop_target;
  674.                if rf8.current_type.is_expanded then
  675.                   ca.opcode_iconst_1;
  676.                else
  677.                   ca.opcode_iconst_0;
  678.                end;
  679.             elseif as_se_argc = name then
  680.                jvm.push_se_argc;
  681.             elseif as_se_argv = name then
  682.                jvm.push_se_argv;
  683.             elseif as_se_getenv = name then
  684.                space := jvm.push_ith_argument(1);
  685.                ca.runtime_se_getenv;
  686.             else
  687.                fe_nyi(rf8);
  688.             end;
  689.          elseif as_platform = bcn then
  690.             jvm.drop_target;
  691.             if as_character_bits = name then
  692.                ca.opcode_bipush(8);
  693.             elseif as_integer_bits = name then
  694.                ca.opcode_bipush(32);
  695.             elseif as_boolean_bits = name then
  696.                ca.opcode_bipush(32);
  697.             elseif as_real_bits = name then
  698.                ca.opcode_bipush(32);
  699.             elseif as_double_bits = name then
  700.                ca.opcode_bipush(64);
  701.             elseif as_pointer_bits = name then
  702.                ca.opcode_bipush(32);
  703.             elseif as_minimum_character_code = name then
  704.                ca.opcode_iconst_i(0);
  705.             elseif as_minimum_double = name then
  706.                idx := cp.idx_fieldref3(fz_java_lang_double,fz_max_value,fz_77);
  707.                ca.opcode_getstatic(idx,2);
  708.                ca.opcode_dneg;
  709.             elseif as_minimum_integer = name then
  710.                ca.opcode_iconst_m1;
  711.                ca.opcode_iconst_1;
  712.                ca.opcode_iushr;
  713.                ca.opcode_ineg;
  714.                ca.opcode_iconst_m1;
  715.                ca.opcode_iadd;
  716.             elseif as_minimum_real = name then
  717.                idx := cp.idx_fieldref3(fz_java_lang_float,fz_max_value,fz_78);
  718.                ca.opcode_getstatic(idx,1);
  719.                ca.opcode_fneg;
  720.             elseif as_maximum_character_code = name then
  721.                ca.opcode_sipush(255);
  722.             elseif as_maximum_double = name then
  723.                idx := cp.idx_fieldref3(fz_java_lang_double,fz_max_value,fz_77);
  724.                ca.opcode_getstatic(idx,2);
  725.             elseif as_maximum_integer = name then
  726.                ca.opcode_iconst_m1;
  727.                ca.opcode_iconst_1;
  728.                ca.opcode_iushr;
  729.             elseif as_maximum_real = name then
  730.                idx := cp.idx_fieldref3(fz_java_lang_float,fz_max_value,fz_78);
  731.                ca.opcode_getstatic(idx,1);
  732.             end;
  733.          elseif as_eof_code = name then
  734.             ca.opcode_iconst_m1;
  735.          elseif as_sfr_open = name then
  736.             jvm_small_eiffel_runtime(name,rf8);
  737.          elseif as_sfw_open = name then
  738.             jvm_small_eiffel_runtime(name,rf8);
  739.          elseif as_se_string2double = name then
  740.             jvm_small_eiffel_runtime(name,rf8);
  741.          elseif as_pointer_size = name then
  742.             ca.opcode_bipush(32);
  743.          elseif as_bit_n = bcn then
  744.             jvm_mapping_bit_function(rf8,name);
  745.          elseif as_item = name then
  746.             jvm.push_target;
  747.             ct := rf8.current_type;
  748.             rc := ct.run_class;
  749.             idx := rc.jvm_constant_pool_index;
  750.             idx := cp.idx_fieldref4(idx,as_item,fz_a9);
  751.             ca.opcode_getfield(idx,0);
  752.          elseif as_read_byte = name then
  753.             space := jvm.push_ith_argument(1);
  754.             ca.read_byte;
  755.          elseif as_exception = name then
  756.             ca.runtime_internal_exception_number;
  757.          elseif as_signal_number = name then
  758.          elseif name.has_prefix(fz_basic_) then
  759.             jvm_small_eiffel_runtime(name,rf8);
  760.          else
  761.             fe_nyi(rf8);
  762.          end;
  763.       end;
  764.  
  765.    jvm_add_method_for_procedure(rf7: RUN_FEATURE_7; bcn, name: STRING) is
  766.       do
  767.       end;
  768.  
  769.    jvm_define_procedure(rf7: RUN_FEATURE_7; bcn, name: STRING) is
  770.       do
  771.       end;
  772.  
  773.    jvm_mapping_procedure(rf7: RUN_FEATURE_7; bcn, name: STRING) is
  774.       local
  775.          ca: like code_attribute;
  776.          cp: like constant_pool;
  777.          space, idx: INTEGER;
  778.          t: TYPE;
  779.       do
  780.          ca := code_attribute;
  781.          cp := constant_pool;
  782.          if as_copy = name or else as_standard_copy = name then
  783.             t := rf7.current_type;
  784.             if t.is_basic_eiffel_expanded then
  785.                jvm.drop_target;
  786.                jvm.drop_ith_argument(1);
  787.             else
  788.                jvm_copy(rf7.current_type);
  789.             end;
  790.          elseif as_flush_stream = name then
  791.             jvm.drop_target;
  792.             space := jvm.push_ith_argument(1);
  793.             idx := cp.idx_class2(fz_25);
  794.             ca.opcode_checkcast(idx);
  795.             idx := cp.idx_methodref1(idx,"flush",fz_29);
  796.             ca.opcode_invokevirtual(idx,-1);
  797.          elseif as_write_byte = name then
  798.             space := jvm.push_ith_argument(1);
  799.             idx := cp.idx_class2(fz_java_io_outputstream);
  800.             ca.opcode_checkcast(idx);
  801.             space := jvm.push_ith_argument(2);
  802.             idx := cp.idx_methodref1(idx,"write",fz_27);
  803.             ca.opcode_invokevirtual(idx,-2);
  804.          elseif as_die_with_code = name then
  805.             jvm.drop_target;
  806.             space := jvm.push_ith_argument(1);
  807.             ca.runtime_die_with_code;
  808.          elseif as_print_run_time_stack = name then
  809.             jvm_small_eiffel_runtime(name,rf7);
  810.          elseif as_native_array = bcn then
  811.             jvm_mapping_native_array_procedure(rf7,name);
  812.          elseif as_sprintf_pointer = name then
  813.             -- *** A FAIRE ***
  814.             jvm.drop_target;
  815.             space := jvm.push_ith_argument(1);
  816.             ca.opcode_dup;
  817.             ca.opcode_iconst_0;
  818.             ca.opcode_bipush(('1').code);
  819.             ca.opcode_bastore;
  820.             ca.opcode_iconst_1;
  821.             ca.opcode_bipush(('0').code);
  822.             ca.opcode_bastore;
  823.          elseif as_sprintf_double = name then
  824.             jvm.push_target;
  825.             space := jvm.push_ith_argument(1);
  826.             space := jvm.push_ith_argument(2);
  827.             idx := cp.idx_methodref3(fz_se_runtime,name,"(D[BI)V");
  828.             ca.opcode_invokestatic(idx,-4);
  829.          elseif as_se_rename = name then
  830.             jvm_small_eiffel_runtime(name,rf7);
  831.          elseif as_se_remove = name then
  832.             jvm_small_eiffel_runtime(name,rf7);
  833.          elseif as_raise_exception = name then
  834.             fe_nyi(rf7);
  835.          elseif as_se_system = name then
  836.             jvm_small_eiffel_runtime(name,rf7);
  837.          elseif as_bit_n = bcn then
  838.             jvm_mapping_bit_procedure(rf7,name);
  839.          else
  840.             fe_nyi(rf7);
  841.          end;
  842.       end;
  843.  
  844. feature
  845.  
  846.    use_current(er: EXTERNAL_ROUTINE): BOOLEAN is
  847.       local
  848.          n: STRING;
  849.       do
  850.          n := er.first_name.to_string;
  851.          if as_se_argc = n then
  852.          elseif as_read_byte = n then
  853.          elseif as_se_argv = n then
  854.          elseif as_se_rename = n then
  855.          elseif as_se_system = n then
  856.          elseif as_write_byte = n then
  857.          else
  858.             Result := true;
  859.          end;
  860.       end;
  861.  
  862. feature {NONE}
  863.  
  864.    jvm_small_eiffel_runtime(name: STRING; rf: RUN_FEATURE) is
  865.          -- Call the corresponding sys/SmallEiffelRutime.java static 
  866.          -- definition of some external "SmallEiffel" feature.
  867.       local
  868.          idx, space: INTEGER;
  869.          fal: FORMAL_ARG_LIST;
  870.          rt: TYPE;
  871.          prototype: STRING;
  872.       do
  873.          fal := rf.arguments;
  874.          rt := rf.result_type;
  875.          jvm.drop_target;
  876.          if fal /= Void then
  877.             space := - jvm.push_arguments;
  878.          end;
  879.          prototype := "(....).";
  880.          prototype.clear;
  881.          prototype.extend('(');
  882.          if fal /= Void then
  883.             fal.jvm_descriptor_in(prototype);
  884.          end;
  885.          prototype.extend(')');
  886.          if rt = Void then
  887.             prototype.extend('V');
  888.          else
  889.             rt.jvm_descriptor_in(prototype);
  890.             space := space + rt.jvm_stack_space;
  891.          end;
  892.          idx := constant_pool.idx_methodref3(fz_se_runtime,name,prototype);
  893.          code_attribute.opcode_invokestatic(idx,space);
  894.       end;
  895.  
  896.    jvm_object_size(ct: TYPE) is
  897.       local
  898.          t: TYPE;
  899.          space, i: INTEGER;
  900.          wa: ARRAY[RUN_FEATURE_2];
  901.       do
  902.          if ct.is_basic_eiffel_expanded then
  903.             space := ct.jvm_stack_space;
  904.          else
  905.             wa := ct.run_class.writable_attributes;
  906.             if wa /= Void then
  907.                from
  908.                   i := wa.upper;
  909.                until
  910.                   i = 0
  911.                loop
  912.                   t := wa.item(i).result_type;
  913.                   space := space + t.jvm_stack_space;
  914.                   i := i - 1;
  915.                end;
  916.             end;
  917.          end;
  918.          code_attribute.opcode_push_integer(space);
  919.       end;
  920.  
  921.    c_mapping_standard_twin(rf8: RUN_FEATURE_8; ct: TYPE) is
  922.       do
  923.          if ct.is_basic_eiffel_expanded then
  924.             cpp.put_target_as_value;
  925.          elseif ct.is_expanded then
  926.             if ct.is_dummy_expanded then
  927.                cpp.put_target_as_target;
  928.             elseif ct.is_native_array then
  929.                cpp.put_target_as_target;
  930.             else
  931.                rf8.default_mapping_function;
  932.             end;
  933.          else
  934.             rf8.default_mapping_function;
  935.          end;
  936.       end;
  937.  
  938.    c_define_standard_twin(rf8: RUN_FEATURE_8; ct: TYPE) is
  939.       do
  940.          if ct.is_basic_eiffel_expanded then
  941.          elseif ct.is_expanded then
  942.             if ct.is_dummy_expanded then
  943.             elseif ct.is_native_array then
  944.             else
  945.                rf8.c_define_with_body("memcpy(&R,C,sizeof(R));");
  946.             end;
  947.          else
  948.             if gc_handler.is_off then
  949.                body.copy("R=malloc(sizeof(*C));%N");
  950.             else
  951.                body.copy("R=(");
  952.                body.append(fz_cast_void_star);
  953.                ct.gc_call_new_in(body);
  954.                body.append(fz_14);
  955.             end;
  956.             body.append("*((T");
  957.             ct.id.append_in(body);
  958.             body.append("*)R)=*C;%N");
  959.             rf8.c_define_with_body(body);
  960.          end;
  961.       end;
  962.  
  963.    c_define_twin(rf8: RUN_FEATURE_8; ct: TYPE; rc: RUN_CLASS;
  964.                  cpy: RUN_FEATURE) is
  965.       require
  966.          rf8 /= Void;
  967.          ct.is_reference or ct.is_user_expanded;
  968.          rc = ct.run_class;
  969.          cpy /= Void
  970.       local
  971.          id: INTEGER;
  972.       do
  973.          rf8.c_opening;
  974.          if ct.is_reference then
  975.             if gc_handler.is_off then
  976.                id := rc.id;
  977.                cpp.put_string("R=malloc(sizeof(*C));%N");
  978.                cpp.put_string("*((T");
  979.                cpp.put_integer(id);
  980.                cpp.put_string("*)R)=M");
  981.                cpp.put_integer(id);
  982.                cpp.put_string(fz_00);
  983.             else
  984.                body.copy("R=((void*)");
  985.                ct.gc_call_new_in(body);
  986.                body.append(fz_14);
  987.                cpp.put_string(body);
  988.             end;
  989.          end;
  990.          cpp.inside_twin(cpy);
  991.          rf8.c_closing;
  992.       end;
  993.  
  994.    jvm_mapping_native_array_function(rf8: RUN_FEATURE_8; name: STRING) is
  995.       local
  996.          elt_type: TYPE;
  997.          space: INTEGER;
  998.          rc: RUN_CLASS;
  999.          loc1, point1, point2: INTEGER;
  1000.          ca: like code_attribute;
  1001.       do
  1002.          elt_type := rf8.current_type.generic_list.item(1).run_type;
  1003.          if as_element_sizeof = name then
  1004.             jvm.drop_target;
  1005.             space := elt_type.jvm_stack_space;
  1006.             code_attribute.opcode_push_integer(space);
  1007.          elseif as_item = name then
  1008.             jvm.push_target;
  1009.             space := jvm.push_ith_argument(1);
  1010.             elt_type.jvm_xaload;
  1011.          elseif as_calloc = name then
  1012.             jvm.drop_target;
  1013.             space := jvm.push_ith_argument(1);
  1014.             elt_type.jvm_xnewarray;
  1015.             if elt_type.is_user_expanded and then
  1016.                not elt_type.is_dummy_expanded
  1017.              then
  1018.                ca := code_attribute;
  1019.                rc := elt_type.run_class;
  1020.                loc1 := ca.extra_local_size1;
  1021.                ca.opcode_dup;
  1022.                ca.opcode_arraylength;
  1023.                ca.opcode_istore(loc1);
  1024.                point1 := ca.program_counter;
  1025.                ca.opcode_iload(loc1);
  1026.                point2 := ca.opcode_ifle;
  1027.                ca.opcode_iinc(loc1,255);
  1028.                ca.opcode_dup;
  1029.                ca.opcode_iload(loc1);
  1030.                rc.jvm_expanded_push_default;
  1031.                ca.opcode_aastore;
  1032.                ca.opcode_goto_backward(point1);
  1033.                ca.resolve_u2_branch(point2);
  1034.             end;
  1035.          elseif name = as_from_pointer then
  1036.             jvm.drop_target;
  1037.             space := jvm.push_ith_argument(1);
  1038.             rf8.current_type.run_class.opcode_checkcast;
  1039.          else
  1040.             fe_nyi(rf8);
  1041.          end;
  1042.       end;
  1043.  
  1044.    jvm_mapping_native_array_procedure(rf7: RUN_FEATURE_7; name: STRING) is
  1045.       local
  1046.          elt_type: TYPE;
  1047.          space: INTEGER;
  1048.       do
  1049.          elt_type := rf7.current_type.generic_list.item(1).run_type;
  1050.          check
  1051.         as_put = name
  1052.      end;
  1053.      jvm.push_target;
  1054.      space := jvm.push_ith_argument(2);
  1055.      space := jvm.push_ith_argument(1);
  1056.      elt_type.jvm_xastore;
  1057.       end;
  1058.  
  1059.    c_mapping_native_array_function(rf8: RUN_FEATURE_8; name: STRING) is
  1060.       local
  1061.          ct, elt_type: TYPE;
  1062.          tcbd: BOOLEAN;
  1063.       do
  1064.      ct := rf8.current_type;
  1065.          elt_type := ct.generic_list.item(1).run_type;
  1066.          if as_element_sizeof = name then
  1067.             tcbd := cpp.target_cannot_be_dropped;
  1068.             if tcbd then
  1069.                cpp.put_character(',');
  1070.             end;
  1071.             tmp_string.copy(fz_sizeof);
  1072.             tmp_string.extend('(');
  1073.             elt_type.c_type_for_argument_in(tmp_string);
  1074.             tmp_string.extend(')');
  1075.             cpp.put_string(tmp_string);
  1076.             if tcbd then
  1077.                cpp.put_character(')');
  1078.             end;
  1079.          elseif name = as_calloc then
  1080.             if elt_type.expanded_initializer = Void then
  1081.                tcbd := cpp.target_cannot_be_dropped;
  1082.                if tcbd then
  1083.                   cpp.put_character(',');
  1084.                end;
  1085.                if gc_handler.is_off then
  1086.                   cpp.put_string("((T");
  1087.           cpp.put_integer(ct.id);
  1088.                   cpp.put_string(")(calloc(");
  1089.                   cpp.put_ith_argument(1);
  1090.                   tmp_string.copy(",sizeof(");
  1091.                   elt_type.c_type_for_result_in(tmp_string);
  1092.                   tmp_string.append("))))");
  1093.                   cpp.put_string(tmp_string);
  1094.                else
  1095.                   cpp.put_string(fz_new);
  1096.                   cpp.put_integer(rf8.current_type.id);
  1097.                   cpp.put_character('(');
  1098.                   cpp.put_ith_argument(1);
  1099.                   cpp.put_character(')');
  1100.                end;
  1101.                if tcbd then
  1102.                   cpp.put_character(')');
  1103.                end;
  1104.             else
  1105.                rf8.default_mapping_function;
  1106.             end;
  1107.          elseif name = as_from_pointer then
  1108.             tcbd := cpp.target_cannot_be_dropped;
  1109.             if tcbd then
  1110.                cpp.put_character(',');
  1111.             end;
  1112.             cpp.put_ith_argument(1);
  1113.             if tcbd then
  1114.                cpp.put_character(')');
  1115.             end;
  1116.          else
  1117.             check
  1118.                as_item = name
  1119.             end;
  1120.             cpp.put_character('(');
  1121.             cpp.put_target_as_value;
  1122.             cpp.put_string(")[");
  1123.             cpp.put_ith_argument(1);
  1124.             cpp.put_character(']');
  1125.          end;
  1126.       end;
  1127.  
  1128.    c_mapping_native_array_procedure(rf7: RUN_FEATURE_7; name: STRING) is
  1129.       local
  1130.          elt_type: TYPE;
  1131.       do
  1132.          elt_type := rf7.current_type.generic_list.item(1).run_type;
  1133.          if name = as_put then
  1134.             if elt_type.is_user_expanded then
  1135.                if elt_type.is_dummy_expanded then
  1136.                   if cpp.cannot_drop_all then
  1137.                      cpp.put_string(fz_14);
  1138.                   end;
  1139.                else
  1140.                   cpp.put_string("memcpy((");
  1141.                   cpp.put_target_as_value;
  1142.                   cpp.put_string(")+(");
  1143.                   cpp.put_ith_argument(2);
  1144.                   cpp.put_string("),&(");
  1145.                   cpp.put_ith_argument(1);
  1146.                   cpp.put_string("),sizeof(T");
  1147.                   cpp.put_integer(elt_type.id);
  1148.                   cpp.put_string(fz_16);
  1149.                end;
  1150.             else
  1151.                cpp.put_character('(');
  1152.                cpp.put_target_as_value;
  1153.                cpp.put_string(")[");
  1154.                cpp.put_ith_argument(2);
  1155.                cpp.put_string("]=(");
  1156.                cpp.put_ith_argument(1);
  1157.                cpp.put_string(fz_14);
  1158.             end;
  1159.          end;
  1160.       end;
  1161.  
  1162.    jvm_copy(t: TYPE) is
  1163.       require
  1164.          not t.is_basic_eiffel_expanded
  1165.       local
  1166.          rc: RUN_CLASS;
  1167.          wa: ARRAY[RUN_FEATURE_2];
  1168.          space: INTEGER;
  1169.       do
  1170.          rc := t.run_class;
  1171.          wa := rc.writable_attributes;
  1172.          jvm.push_target;
  1173.          space := jvm.push_ith_argument(1);
  1174.          rc.opcode_checkcast;
  1175.          jvm.fields_by_fields_copy(wa);
  1176.          code_attribute.opcode_pop;
  1177.       end;
  1178.  
  1179.    jvm_define_twin(rf8: RUN_FEATURE_8; rc: RUN_CLASS; cpy: RUN_FEATURE) is
  1180.       require
  1181.          rc = rf8.current_type.run_class;
  1182.          cpy /= Void
  1183.       local
  1184.          idx, space, i: INTEGER;
  1185.          wa: ARRAY[RUN_FEATURE_2];
  1186.          rf2: RUN_FEATURE_2;
  1187.       do
  1188.          rf8.jvm_opening;
  1189.          wa := rc.writable_attributes;
  1190.          rc.jvm_basic_new;
  1191.          code_attribute.opcode_astore_1;
  1192.          if wa /= Void then
  1193.             from
  1194.                i := wa.upper;
  1195.             until
  1196.                i = 0
  1197.             loop
  1198.                rf2 := wa.item(i);
  1199.                code_attribute.opcode_aload_1;
  1200.                idx := constant_pool.idx_fieldref(rf2);
  1201.                space := rf2.result_type.jvm_push_default;
  1202.                code_attribute.opcode_putfield(idx,-(space + 1));
  1203.                i := i - 1;
  1204.             end;
  1205.          end;
  1206.          jvm.inside_twin(cpy);
  1207.          rf8.jvm_closing;
  1208.       end;
  1209.  
  1210. feature {NONE}
  1211.  
  1212.    jvm_standard_twin(t: TYPE) is
  1213.       require
  1214.          t /= Void
  1215.       local
  1216.          rc: RUN_CLASS;
  1217.          wa: ARRAY[RUN_FEATURE_2];
  1218.       do
  1219.          if t.is_basic_eiffel_expanded or else t.is_native_array then
  1220.             jvm.push_target;
  1221.          else
  1222.             rc := t.run_class;
  1223.             wa := rc.writable_attributes;
  1224.             if t.is_expanded then
  1225.                if wa = Void then
  1226.                   jvm.push_target;
  1227.                else
  1228.                   jvm_standard_twin_aux(rc,wa);
  1229.                end;
  1230.             else
  1231.                jvm_standard_twin_aux(rc,wa);
  1232.             end;
  1233.          end;
  1234.       end;
  1235.  
  1236.    jvm_standard_twin_aux(rc: RUN_CLASS; wa: ARRAY[RUN_FEATURE_2]) is
  1237.       require
  1238.          rc /= Void
  1239.       local
  1240.          ca: like code_attribute;
  1241.          rf2: RUN_FEATURE_2;
  1242.          idx, space, i: INTEGER;
  1243.       do
  1244.          ca := code_attribute;
  1245.          rc.jvm_basic_new;
  1246.          if wa = Void then
  1247.             jvm.drop_target;
  1248.          else
  1249.             jvm.push_target;
  1250.             rc.opcode_checkcast;
  1251.             from
  1252.                i := wa.upper;
  1253.             until
  1254.                i = 0
  1255.             loop
  1256.                rf2 := wa.item(i);
  1257.                ca.opcode_dup2;
  1258.                idx := constant_pool.idx_fieldref(rf2);
  1259.                space := rf2.result_type.jvm_stack_space;
  1260.                ca.opcode_getfield(idx,space - 1);
  1261.                ca.opcode_putfield(idx,space + 1);
  1262.                i := i - 1;
  1263.             end;
  1264.             ca.opcode_pop;
  1265.          end;
  1266.       end;
  1267.  
  1268.    jvm_mapping_integer_function(rf8: RUN_FEATURE_8; name: STRING) is
  1269.       local
  1270.          point1, point2, space: INTEGER;
  1271.          ca: like code_attribute;
  1272.       do
  1273.          ca := code_attribute;
  1274.          if as_slash = name then
  1275.             jvm.push_target;
  1276.             ca.opcode_i2d;
  1277.             space := jvm.push_ith_argument(1);
  1278.             ca.opcode_i2d;
  1279.             ca.opcode_ddiv;
  1280.          elseif rf8.arg_count = 1 then
  1281.             jvm.push_target;
  1282.             space := jvm.push_ith_argument(1);
  1283.             if as_plus = name then
  1284.                ca.opcode_iadd;
  1285.             elseif as_minus = name then
  1286.                ca.opcode_isub;
  1287.             elseif as_muls = name then
  1288.                ca.opcode_imul;
  1289.             elseif as_slash_slash = name then
  1290.                ca.opcode_idiv;
  1291.             elseif as_backslash_backslash = name then
  1292.                ca.opcode_irem;
  1293.             else -- < > <= >= only
  1294.                if as_gt = name then
  1295.                   point1 := ca.opcode_if_icmpgt;
  1296.                elseif as_lt = name then
  1297.                   point1 := ca.opcode_if_icmplt;
  1298.                elseif as_le = name then
  1299.                   point1 := ca.opcode_if_icmple;
  1300.                else
  1301.                   point1 := ca.opcode_if_icmpge;
  1302.                end;
  1303.                ca.opcode_iconst_0;
  1304.                point2 := ca.opcode_goto;
  1305.                ca.resolve_u2_branch(point1);
  1306.                ca.opcode_iconst_1;
  1307.                ca.resolve_u2_branch(point2);
  1308.             end;
  1309.          elseif as_to_character = name then
  1310.             jvm.push_target;
  1311.             code_attribute.opcode_i2b;
  1312.          elseif as_to_bit = name then
  1313.             jvm_int_to_bit(rf8.result_type,32);
  1314.          else
  1315.             check
  1316.                as_minus = name
  1317.             end;
  1318.             jvm.push_target;
  1319.             code_attribute.opcode_ineg
  1320.          end;
  1321.       end;
  1322.  
  1323.    jvm_mapping_real_function(rf8: RUN_FEATURE_8; name: STRING) is
  1324.       local
  1325.          point1, point2, space: INTEGER;
  1326.          ca: like code_attribute;
  1327.       do
  1328.          ca := code_attribute;
  1329.          if rf8.arg_count = 1 then
  1330.             jvm.push_target;
  1331.             space := jvm.push_ith_argument(1);
  1332.             if as_plus = name then
  1333.                ca.opcode_fadd;
  1334.             elseif as_minus = name then
  1335.                ca.opcode_fsub;
  1336.             elseif as_muls = name then
  1337.                ca.opcode_fmul;
  1338.             elseif as_slash = name then
  1339.                ca.opcode_fdiv;
  1340.             else
  1341.                ca.opcode_fcmpg;
  1342.                if as_gt = name then     -- gt
  1343.                   point1 := ca.opcode_ifgt;
  1344.                elseif as_lt = name then -- lt
  1345.                   point1 := ca.opcode_iflt;
  1346.                elseif as_le = name then -- le
  1347.                   point1 := ca.opcode_ifle;
  1348.                elseif as_ge = name then -- ge
  1349.                   point1 := ca.opcode_ifge;
  1350.                end;
  1351.                ca.opcode_iconst_0;
  1352.                point2 := ca.opcode_goto;
  1353.                ca.resolve_u2_branch(point1);
  1354.                ca.opcode_iconst_1;
  1355.                ca.resolve_u2_branch(point2);
  1356.             end;
  1357.          elseif as_minus = name then
  1358.             jvm.push_target;
  1359.             ca.opcode_fneg
  1360.          elseif as_to_double = name then
  1361.             jvm.push_target;
  1362.             ca.opcode_f2d;
  1363.          end;
  1364.       end;
  1365.  
  1366.    jvm_mapping_double_function(rf8: RUN_FEATURE_8; name: STRING) is
  1367.       local
  1368.          point1, point2, space, idx: INTEGER;
  1369.          ca: like code_attribute;
  1370.       do
  1371.          ca := code_attribute;
  1372.          if rf8.arg_count = 1 then
  1373.             jvm.push_target;
  1374.             space := jvm.push_ith_argument(1);
  1375.             if as_plus = name then
  1376.                ca.opcode_dadd;
  1377.             elseif as_minus = name then
  1378.                ca.opcode_dsub;
  1379.             elseif as_muls = name then
  1380.                ca.opcode_dmul;
  1381.             elseif as_slash = name then
  1382.                ca.opcode_ddiv;
  1383.             elseif as_pow = name then
  1384.                ca.opcode_i2d;
  1385.                idx := constant_pool.idx_methodref3(fz_java_lang_math,"pow",fz_99);
  1386.                ca.opcode_invokestatic(idx,-2);
  1387.             else
  1388.                ca.opcode_dcmpg;
  1389.                if as_gt = name then     -- gt
  1390.                   point1 := ca.opcode_ifgt;
  1391.                elseif as_lt = name then -- lt
  1392.                   point1 := ca.opcode_iflt;
  1393.                elseif as_le = name then -- le
  1394.                   point1 := ca.opcode_ifle;
  1395.                elseif as_ge = name then -- ge
  1396.                   point1 := ca.opcode_ifge;
  1397.                end;
  1398.                ca.opcode_iconst_0;
  1399.                point2 := ca.opcode_goto;
  1400.                ca.resolve_u2_branch(point1);
  1401.                ca.opcode_iconst_1;
  1402.                ca.resolve_u2_branch(point2);
  1403.             end;
  1404.          elseif as_minus = name then
  1405.             jvm.push_target;
  1406.             ca.opcode_dneg;
  1407.          elseif as_to_real = name then
  1408.             jvm.push_target;
  1409.             ca.opcode_d2f;
  1410.          elseif as_double_floor = name then
  1411.             jvm.push_target;
  1412.             idx := constant_pool.idx_methodref3(fz_java_lang_math,as_floor,fz_94);
  1413.             ca.opcode_invokestatic(idx,0);
  1414.          elseif as_truncated_to_integer = name then
  1415.             jvm.push_target;
  1416.             idx := constant_pool.idx_methodref3(fz_java_lang_math,as_floor,fz_94);
  1417.             ca.opcode_invokestatic(idx,0);
  1418.             ca.opcode_d2i;
  1419.          else -- Same name in java/lang/Math :
  1420.             jvm.push_target;
  1421.             idx := constant_pool.idx_methodref3(fz_java_lang_math,name,fz_94);
  1422.             ca.opcode_invokestatic(idx,0);
  1423.          end;
  1424.       end;
  1425.  
  1426. feature {NONE}
  1427.  
  1428.    c_mapping_integer_function(rf8: RUN_FEATURE_8; name: STRING) is
  1429.       do
  1430.          if rf8.arg_count = 1 then
  1431.             if as_slash = name then
  1432.                cpp.put_string("((T5)");
  1433.             end;
  1434.             cpp.put_character('(');
  1435.             cpp.put_target_as_value;
  1436.             if as_slash = name then
  1437.                cpp.put_character(')');
  1438.             end;
  1439.             cpp.put_character(')');
  1440.             if as_slash_slash = name then
  1441.                cpp.put_character('/');
  1442.             elseif as_backslash_backslash = name then
  1443.                cpp.put_character('%%');
  1444.             else
  1445.                cpp.put_string(name);
  1446.             end;
  1447.             cpp.put_character('(');
  1448.             cpp.put_arguments;
  1449.             cpp.put_character(')');
  1450.          elseif as_to_character = name then
  1451.             cpp.put_string("((T3)(");
  1452.             cpp.put_target_as_value;
  1453.             cpp.put_string(fz_13);
  1454.          elseif as_to_bit = name then
  1455.             cpp.put_target_as_value;
  1456.          else
  1457.             cpp.put_string(name);
  1458.             cpp.put_character('(');
  1459.             cpp.put_target_as_value;
  1460.             cpp.put_character(')');
  1461.          end;
  1462.       end;
  1463.  
  1464.    c_mapping_real_function(rf8: RUN_FEATURE_8; name: STRING) is
  1465.       do
  1466.          if rf8.arg_count = 1 then
  1467.             cpp.put_character('(');
  1468.             cpp.put_target_as_value;
  1469.             cpp.put_character(')');
  1470.             cpp.put_string(name);
  1471.             cpp.put_character('(');
  1472.             cpp.put_arguments;
  1473.             cpp.put_character(')');
  1474.          elseif as_to_double = name then
  1475.             cpp.put_string("((T5)(");
  1476.             cpp.put_target_as_value;
  1477.             cpp.put_string(fz_13);
  1478.          else
  1479.             cpp.put_string(name);
  1480.             cpp.put_character('(');
  1481.             cpp.put_target_as_value;
  1482.             cpp.put_character(')');
  1483.          end;
  1484.       end;
  1485.  
  1486.    c_mapping_double_function(rf8: RUN_FEATURE_8; name: STRING) is
  1487.       do
  1488.          if as_pow = name then
  1489.             system_tools.add_lib_math;
  1490.             cpp.put_string("pow((");
  1491.             cpp.put_target_as_value;
  1492.             cpp.put_string("),(double)(");
  1493.             cpp.put_arguments;
  1494.             cpp.put_string(fz_13);
  1495.          elseif as_double_floor = name then
  1496.             system_tools.add_lib_math;
  1497.             cpp.put_string(as_floor);
  1498.             cpp.put_character('(');
  1499.             cpp.put_target_as_value;
  1500.             cpp.put_character(')');
  1501.          elseif as_truncated_to_integer = name then
  1502.             system_tools.add_lib_math;
  1503.             cpp.put_string("((int)floor(");
  1504.             cpp.put_target_as_value;
  1505.             cpp.put_string(fz_13);
  1506.          elseif as_to_real = name then
  1507.             cpp.put_string("((T4)(");
  1508.             cpp.put_target_as_value;
  1509.             cpp.put_string(fz_13);
  1510.          elseif name.count <= 2 and then rf8.arg_count = 1 then
  1511.             cpp.put_character('(');
  1512.             cpp.put_target_as_value;
  1513.             cpp.put_character(')');
  1514.             cpp.put_string(name);
  1515.             cpp.put_character('(');
  1516.             cpp.put_arguments;
  1517.             cpp.put_character(')');
  1518.          else
  1519.             system_tools.add_lib_math;
  1520.             cpp.put_string(name);
  1521.             cpp.put_character('(');
  1522.             cpp.put_target_as_value;
  1523.             cpp.put_character(')');
  1524.          end;
  1525.       end;
  1526.  
  1527.    c_define_procedure_bit(rf7: RUN_FEATURE_7; n: STRING) is
  1528.       local
  1529.          type_bit: TYPE_BIT;
  1530.       do
  1531.          type_bit ?= rf7.current_type;
  1532.          if as_put_0 = n then
  1533.             if type_bit.is_c_unsigned_ptr then
  1534.                body.clear;
  1535.                body_long_bit_put01(type_bit,'&','~','1');
  1536.                rf7.c_define_with_body(body);
  1537.             end;
  1538.          elseif as_put_1 = n then
  1539.             if type_bit.is_c_unsigned_ptr then
  1540.                body.clear;
  1541.                body_long_bit_put01(type_bit,'|',' ','1');
  1542.                rf7.c_define_with_body(body);
  1543.             end;
  1544.          elseif as_put = n then
  1545.             if type_bit.is_c_unsigned_ptr then
  1546.                body.clear;
  1547.                body.append("if(a1)%N");
  1548.                body_long_bit_put01(type_bit,'|',' ','2');
  1549.                body.append(fz_else);
  1550.                body_long_bit_put01(type_bit,'&','~','2');
  1551.                rf7.c_define_with_body(body);
  1552.             end;
  1553.          end;
  1554.       end;
  1555.  
  1556. feature {NONE}
  1557.  
  1558.    tmp_string: STRING is
  1559.       once
  1560.          !!Result.make(32);
  1561.       end;
  1562.  
  1563. feature {NONE}
  1564.  
  1565.    fe_long_bit(rf: RUN_FEATURE) is
  1566.       do
  1567.          eh.add_position(rf.start_position);
  1568.          eh.append("Sorry, this feature cannot be implemented for ");
  1569.          eh.add_type(rf.current_type,
  1570.           " (bit string too long). You should probably consider using %
  1571.           %the BIT_STRING class to work around.");
  1572.          eh.print_as_fatal_error;
  1573.       end;
  1574.  
  1575.    fe_nyi(rf: RUN_FEATURE) is
  1576.       do
  1577.          eh.add_position(rf.start_position);
  1578.          eh.append("Sorry, but this feature is not yet implemented for %
  1579.                    %Current type ");
  1580.          eh.append(rf.current_type.run_time_mark);
  1581.          fatal_error(" (if you cannot work around mail %"colnet@loria.fr%").");
  1582.       end;
  1583.  
  1584.    jvm_bit_to_int(size: INTEGER) is
  1585.       local
  1586.          idx: INTEGER;
  1587.          point1, point2: INTEGER;
  1588.          loc1, loc2: INTEGER;
  1589.          ca: like code_attribute;
  1590.          cp: like constant_pool;
  1591.       do
  1592.          ca := code_attribute;
  1593.          cp := constant_pool;
  1594.          jvm.push_target;
  1595.          loc1 := ca.extra_local_size1;
  1596.          ca.opcode_iconst_0;
  1597.          ca.opcode_istore(loc1);
  1598.          loc2 := ca.extra_local_size1;
  1599.          ca.opcode_iconst_0;
  1600.          ca.opcode_istore(loc2);
  1601.          ca.opcode_iconst_1;
  1602.          point1 := ca.program_counter;
  1603.          point2 := ca.opcode_ifeq;
  1604.          ca.opcode_iload(loc2);
  1605.          ca.opcode_iconst_1;
  1606.          ca.opcode_ishl;
  1607.          ca.opcode_istore(loc2);
  1608.          ca.opcode_dup;
  1609.          ca.opcode_iload(loc1);
  1610.          idx := cp.idx_methodref3(fz_java_util_bitset,fz_a2,fz_a3);
  1611.          ca.opcode_invokevirtual(idx,-1);
  1612.          ca.opcode_iload(loc2);
  1613.          ca.opcode_ior;
  1614.          ca.opcode_istore(loc2);
  1615.          ca.opcode_iinc(loc1,1);
  1616. -- ***
  1617. -- ca.opcode_dup;
  1618. --     idx := cp.idx_methodref3(fz_java_util_bitset,"size",fz_71);
  1619. --     ca.opcode_invokevirtual(idx,0);
  1620.          ca.opcode_push_integer(size);
  1621. -- ***
  1622.          ca.opcode_iload(loc1);
  1623.          ca.opcode_isub;
  1624.          ca.opcode_goto_backward(point1);
  1625.          ca.resolve_u2_branch(point2);
  1626.          ca.opcode_pop;
  1627.          ca.opcode_iload(loc2);
  1628.       end;
  1629.  
  1630.    jvm_int_to_bit(type_bit: TYPE; nb_bit: INTEGER) is
  1631.       local
  1632.          idx: INTEGER;
  1633.          point1, point2, point3: INTEGER;
  1634.          loc1, loc2: INTEGER;
  1635.          ca: like code_attribute;
  1636.          cp: like constant_pool;
  1637.       do
  1638.          ca := code_attribute;
  1639.          cp := constant_pool;
  1640.          jvm.push_target;
  1641.          loc1 := ca.extra_local_size1;
  1642.          ca.opcode_push_integer(nb_bit);
  1643.          ca.opcode_istore(loc1);
  1644.          loc2 := ca.extra_local_size1;
  1645.          idx := type_bit.jvm_push_default;
  1646.          ca.opcode_astore(loc2);
  1647.          ca.opcode_iconst_1;
  1648.          point1 := ca.program_counter;
  1649.          point2 := ca.opcode_ifeq;
  1650.          ca.opcode_iinc(loc1,255);
  1651.          ca.opcode_dup;
  1652.          ca.opcode_iconst_1;
  1653.          ca.opcode_iand;
  1654.          point3 := ca.opcode_ifeq;
  1655.          ca.opcode_aload(loc2);
  1656.          ca.opcode_iload(loc1);
  1657.          idx := cp.idx_methodref3(fz_java_util_bitset,fz_a4,fz_27);
  1658.          ca.opcode_invokevirtual(idx,-2);
  1659.          ca.resolve_u2_branch(point3);
  1660.          ca.opcode_iconst_1;
  1661.          ca.opcode_iushr;
  1662.          ca.opcode_iload(loc1);
  1663.          ca.opcode_goto_backward(point1);
  1664.          ca.resolve_u2_branch(point2);
  1665.          ca.opcode_pop;
  1666.          ca.opcode_aload(loc2);
  1667.       end;
  1668.  
  1669.    jvm_mapping_bit_function(rf8: RUN_FEATURE_8; name: STRING) is
  1670.       local
  1671.          type_bit: TYPE_BIT;
  1672.          space, idx: INTEGER;
  1673.          point1, point2, point3: INTEGER;
  1674.          loc1, loc2: INTEGER;
  1675.          ca: like code_attribute;
  1676.          cp: like constant_pool;
  1677.       do
  1678.          ca := code_attribute;
  1679.          cp := constant_pool;
  1680.          type_bit ?= rf8.current_type;
  1681.          if as_count = name then
  1682.             jvm.drop_target;
  1683.             ca.opcode_push_integer(type_bit.nb);
  1684.          elseif as_item = name then
  1685.             jvm.push_target;
  1686.             space := jvm.push_ith_argument(1);
  1687.             ca.opcode_iconst_1;
  1688.             ca.opcode_isub;
  1689.             idx := cp.idx_methodref3(fz_java_util_bitset,fz_a2,fz_a3);
  1690.             ca.opcode_invokevirtual(idx,-1);
  1691.          elseif as_shift_right = name then
  1692.             jvm.push_target;
  1693.             space := jvm.push_ith_argument(1);
  1694.             loc1 := ca.extra_local_size1;
  1695.             loc2 := ca.extra_local_size1;
  1696.             ca.opcode_istore(loc2);
  1697.             space := type_bit.jvm_push_default;
  1698.             ca.opcode_swap;
  1699.             ca.opcode_push_integer(type_bit.nb);
  1700.             ca.opcode_istore(loc1);
  1701.             ca.opcode_iload(loc1);
  1702.             ca.opcode_iload(loc2);
  1703.             ca.opcode_isub;
  1704.             ca.opcode_istore(loc2);
  1705.             ca.opcode_iload(loc2);
  1706.             point1 := ca.program_counter;
  1707.             point2 := ca.opcode_ifeq;
  1708.             ca.opcode_iinc(loc1,255);
  1709.             ca.opcode_iinc(loc2,255);
  1710.             ca.opcode_dup2;
  1711.             ca.opcode_iload(loc2);
  1712.             idx := cp.idx_methodref3(fz_java_util_bitset,fz_a2,fz_a3);
  1713.             ca.opcode_invokevirtual(idx,-1);
  1714.             point3 := ca.opcode_ifne;
  1715.             ca.opcode_pop;
  1716.             ca.opcode_iload(loc2);
  1717.             ca.opcode_goto_backward(point1);
  1718.             ca.resolve_u2_branch(point3);
  1719.             ca.opcode_iload(loc1);
  1720.             idx := cp.idx_methodref3(fz_java_util_bitset,fz_a4,fz_27);
  1721.             ca.opcode_invokevirtual(idx,-2);
  1722.             ca.opcode_iload(loc2);
  1723.             ca.opcode_goto_backward(point1);
  1724.             ca.resolve_u2_branch(point2);
  1725.             ca.opcode_pop;
  1726.          elseif as_shift_left = name then
  1727.             jvm.push_target;
  1728.             space := jvm.push_ith_argument(1);
  1729.             loc1 := ca.extra_local_size1;
  1730.             loc2 := ca.extra_local_size1;
  1731.             ca.opcode_istore(loc1);
  1732.             space := type_bit.jvm_push_default;
  1733.             ca.opcode_swap;
  1734.             ca.opcode_push_integer(type_bit.nb);
  1735.             ca.opcode_istore(loc2);
  1736.             ca.opcode_iload(loc2);
  1737.             ca.opcode_iload(loc1);
  1738.             ca.opcode_isub;
  1739.             ca.opcode_istore(loc1);
  1740.             ca.opcode_iload(loc1);
  1741.             point1 := ca.program_counter;
  1742.             point2 := ca.opcode_ifeq;
  1743.             ca.opcode_iinc(loc1,255);
  1744.             ca.opcode_iinc(loc2,255);
  1745.             ca.opcode_dup2;
  1746.             ca.opcode_iload(loc2);
  1747.             idx := cp.idx_methodref3(fz_java_util_bitset,fz_a2,fz_a3);
  1748.             ca.opcode_invokevirtual(idx,-1);
  1749.             point3 := ca.opcode_ifne;
  1750.             ca.opcode_pop;
  1751.             ca.opcode_iload(loc1);
  1752.             ca.opcode_goto_backward(point1);
  1753.             ca.resolve_u2_branch(point3);
  1754.             ca.opcode_iload(loc1);
  1755.             idx := cp.idx_methodref3(fz_java_util_bitset,fz_a4,fz_27);
  1756.             ca.opcode_invokevirtual(idx,-2);
  1757.             ca.opcode_iload(loc1);
  1758.             ca.opcode_goto_backward(point1);
  1759.             ca.resolve_u2_branch(point2);
  1760.             ca.opcode_pop;
  1761.          elseif as_xor = name then
  1762.             jvm.push_target;
  1763.             ca.opcode_dup;
  1764.             space := jvm.push_ith_argument(1);
  1765.             idx := cp.idx_methodref3(fz_java_util_bitset,as_xor,fz_b1);
  1766.             ca.opcode_invokevirtual(idx,0);
  1767.          elseif as_or = name then
  1768.             jvm.push_target;
  1769.             ca.opcode_dup;
  1770.             space := jvm.push_ith_argument(1);
  1771.             idx := cp.idx_methodref3(fz_java_util_bitset,as_or,fz_b1);
  1772.             ca.opcode_invokevirtual(idx,0);
  1773.          elseif as_not = name then
  1774.             jvm.push_target;
  1775.             loc1 := ca.extra_local_size1;
  1776.             ca.opcode_push_integer(type_bit.nb);
  1777.             ca.opcode_istore(loc1);
  1778.             ca.opcode_iload(loc1);
  1779.             point1 := ca.program_counter;
  1780.             point2 := ca.opcode_ifeq;
  1781.             ca.opcode_iinc(loc1,255);
  1782.             ca.opcode_dup;
  1783.             ca.opcode_iload(loc1);
  1784.             idx := cp.idx_methodref3(fz_java_util_bitset,fz_a2,fz_a3);
  1785.             ca.opcode_invokevirtual(idx,-1);
  1786.             point3 := ca.opcode_ifne;
  1787.             ca.opcode_dup;
  1788.             ca.opcode_iload(loc1);
  1789.             idx := cp.idx_methodref3(fz_java_util_bitset,fz_a4,fz_27);
  1790.             ca.opcode_invokevirtual(idx,-2);
  1791.             ca.opcode_iload(loc1);
  1792.             ca.opcode_goto_backward(point1);
  1793.             ca.resolve_u2_branch(point3);
  1794.             ca.opcode_dup;
  1795.             ca.opcode_iload(loc1);
  1796.             idx := cp.idx_methodref3(fz_java_util_bitset,fz_a5,fz_27);
  1797.             ca.opcode_invokevirtual(idx,-2);
  1798.             ca.opcode_iload(loc1);
  1799.             ca.opcode_goto_backward(point1);
  1800.             ca.resolve_u2_branch(point2);
  1801.          elseif as_and = name then
  1802.             jvm.push_target;
  1803.             ca.opcode_dup;
  1804.             space := jvm.push_ith_argument(1);
  1805.             idx := cp.idx_methodref3(fz_java_util_bitset,as_and,fz_b1);
  1806.             ca.opcode_invokevirtual(idx,0);
  1807.          elseif as_to_character = name then
  1808.             jvm_bit_to_int(8);
  1809.          elseif as_to_integer = name then
  1810.             jvm_bit_to_int(32);
  1811.          end;
  1812.       end;
  1813.  
  1814.    jvm_mapping_bit_procedure(rf7: RUN_FEATURE_7; name: STRING) is
  1815.       local
  1816.          type_bit: TYPE_BIT;
  1817.          space, idx, point1, point2: INTEGER;
  1818.          ca: like code_attribute;
  1819.          cp: like constant_pool;
  1820.       do
  1821.          ca := code_attribute;
  1822.          cp := constant_pool;
  1823.          type_bit ?= rf7.current_type;
  1824.          if name = as_put_0 then
  1825.             jvm.push_target;
  1826.             space := jvm.push_ith_argument(1);
  1827.             ca.opcode_iconst_1;
  1828.             ca.opcode_isub;
  1829.             idx := cp.idx_methodref3(fz_java_util_bitset,fz_a5,fz_27);
  1830.             ca.opcode_invokevirtual(idx,-2);
  1831.          elseif name = as_put_1 then
  1832.             jvm.push_target;
  1833.             space := jvm.push_ith_argument(1);
  1834.             ca.opcode_iconst_1;
  1835.             ca.opcode_isub;
  1836.             idx := cp.idx_methodref3(fz_java_util_bitset,fz_a4,fz_27);
  1837.             ca.opcode_invokevirtual(idx,-2);
  1838.          else
  1839.             check
  1840.                name = as_put
  1841.             end;
  1842.             jvm.push_target;
  1843.             space := jvm.push_ith_argument(1);
  1844.             space := jvm.push_ith_argument(2);
  1845.             ca.opcode_iconst_1;
  1846.             ca.opcode_isub;
  1847.             ca.opcode_swap;
  1848.             point1 := ca.opcode_ifne;
  1849.             idx := cp.idx_methodref3(fz_java_util_bitset,fz_a5,fz_27);
  1850.             ca.opcode_invokevirtual(idx,-2);
  1851.             point2 := ca.opcode_goto;
  1852.             ca.resolve_u2_branch(point1);
  1853.             idx := cp.idx_methodref3(fz_java_util_bitset,fz_a4,fz_27);
  1854.             ca.opcode_invokevirtual(idx,-2);
  1855.             ca.resolve_u2_branch(point2);
  1856.          end;
  1857.       end;
  1858.  
  1859.    c_mapping_bit_procedure(rf7: RUN_FEATURE_7; name: STRING) is
  1860.       local
  1861.          type_bit: TYPE_BIT;
  1862.       do
  1863.          type_bit ?= rf7.current_type;
  1864.          if name = as_put_0 then
  1865.             if type_bit.is_c_unsigned_ptr then
  1866.                rf7.default_mapping_procedure;
  1867.             else
  1868.                mapping_small_bit_put_0(type_bit,1);
  1869.             end;
  1870.          elseif name = as_put_1 then
  1871.             if type_bit.is_c_unsigned_ptr then
  1872.                rf7.default_mapping_procedure;
  1873.             else
  1874.                mapping_small_bit_put_1(type_bit,1);
  1875.             end;
  1876.          else
  1877.             check
  1878.                name = as_put
  1879.             end;
  1880.             if type_bit.is_c_unsigned_ptr then
  1881.                rf7.default_mapping_procedure;
  1882.             else
  1883.                cpp.put_string("if(");
  1884.                cpp.put_ith_argument(1);
  1885.                cpp.put_string("){%N");
  1886.                mapping_small_bit_put_1(type_bit,2);
  1887.                cpp.put_string("} else {%N");
  1888.                mapping_small_bit_put_0(type_bit,2);
  1889.                cpp.put_string(fz_12);
  1890.             end;
  1891.          end;
  1892.       end;
  1893.  
  1894.    body_long_bit_put01(type_bit: TYPE_BIT; op1, op2, arg: CHARACTER) is
  1895.       require
  1896.          type_bit.is_c_unsigned_ptr
  1897.       do
  1898.          body.append("{%N%
  1899.                      %unsigned int*ptr=((void*)C);%N%
  1900.                      %int ib=(CHAR_BIT*sizeof(int));%N%
  1901.                      %int widx=((");
  1902.          type_bit.unsigned_padding.append_in(body);
  1903.          body.append("+a");
  1904.          body.extend(arg);
  1905.          body.append("-1)/ib);%N%
  1906.                      %int bidx=((a");
  1907.          body.extend(arg);
  1908.          body.append("-1+");
  1909.          type_bit.unsigned_padding.append_in(body);
  1910.          body.append(")%%ib)+1;%N%
  1911.                      %int shift=ib-bidx;%N%
  1912.                      %(*(ptr+widx))");
  1913.          body.extend(op1);
  1914.          body.append("=(");
  1915.          body.extend(op2);
  1916.          body.append("(((unsigned int)1)<<shift));%N}");
  1917.       end;
  1918.  
  1919.    mapping_small_bit_put01(type_bit: TYPE_BIT; op1, op2: CHARACTER; arg: INTEGER) is
  1920.       require
  1921.          not type_bit.is_c_unsigned_ptr
  1922.       do
  1923.          cpp.put_target_as_value;
  1924.          cpp.put_character(op1);
  1925.          cpp.put_string("=(");
  1926.          cpp.put_character(op2);
  1927.          cpp.put_string("(((unsigned ");
  1928.          if type_bit.is_c_char then
  1929.             cpp.put_string(fz_char);
  1930.          else
  1931.             cpp.put_string(fz_int);
  1932.          end;
  1933.          cpp.put_string(")1)<<(");
  1934.          cpp.put_integer(type_bit.nb);
  1935.          cpp.put_string("-(");
  1936.          cpp.put_ith_argument(arg);
  1937.          cpp.put_string("))));%N");
  1938.       end;
  1939.  
  1940.    mapping_small_bit_put_1(type_bit: TYPE_BIT; arg: INTEGER) is
  1941.       require
  1942.          not type_bit.is_c_unsigned_ptr
  1943.       do
  1944.          mapping_small_bit_put01(type_bit,'|',' ',arg);
  1945.       end;
  1946.  
  1947.    mapping_small_bit_put_0(type_bit: TYPE_BIT; arg: INTEGER) is
  1948.       require
  1949.          not type_bit.is_c_unsigned_ptr
  1950.       do
  1951.          mapping_small_bit_put01(type_bit,'&','~',arg);
  1952.       end;
  1953.  
  1954.    c_mapping_bit_function(rf8: RUN_FEATURE_8; name: STRING) is
  1955.       local
  1956.          type_bit: TYPE_BIT;
  1957.          boost: BOOLEAN;
  1958.       do
  1959.          type_bit ?= rf8.current_type;
  1960.          boost := run_control.boost;
  1961.          if as_count = name then
  1962.             cpp.put_integer(type_bit.nb);
  1963.          elseif as_item = name then
  1964.             if type_bit.is_c_unsigned_ptr then
  1965.                rf8.default_mapping_function;
  1966.             elseif boost then
  1967.                cpp.put_string("(((unsigned int)(");
  1968.                cpp.put_target_as_target;
  1969.                cpp.put_string(")>>(");
  1970.                cpp.put_integer(type_bit.nb);
  1971.                cpp.put_string("-(");
  1972.                cpp.put_arguments;
  1973.                cpp.put_string(")))&1)");
  1974.             else
  1975.                rf8.default_mapping_function;
  1976.             end;
  1977.          elseif as_shift_right = name then
  1978.             if type_bit.is_c_unsigned_ptr then
  1979.                fe_long_bit(rf8);
  1980.             elseif boost then
  1981.                cpp.put_string(fz_17);
  1982.                cpp.put_target_as_target;
  1983.                cpp.put_string(")>>(");
  1984.                cpp.put_ith_argument(1);
  1985.                cpp.put_string(fz_13);
  1986.             else
  1987.                rf8.default_mapping_function;
  1988.             end;
  1989.          elseif as_shift_left = name then
  1990.             if type_bit.is_c_unsigned_ptr then
  1991.                fe_long_bit(rf8);
  1992.             elseif boost then
  1993.                cpp.put_string(fz_17);
  1994.                cpp.put_target_as_target;
  1995.                cpp.put_string(")<<(");
  1996.                cpp.put_ith_argument(1);
  1997.                cpp.put_string(fz_13);
  1998.             else
  1999.                rf8.default_mapping_function;
  2000.             end;
  2001.          elseif as_xor = name then
  2002.             if type_bit.is_c_unsigned_ptr then
  2003.                fe_long_bit(rf8);
  2004.             else
  2005.                cpp.put_character('(');
  2006.                cpp.put_target_as_target;
  2007.                cpp.put_character(')');
  2008.                cpp.put_character('^');
  2009.                cpp.put_character('(');
  2010.                cpp.put_ith_argument(1);
  2011.                cpp.put_character(')');
  2012.             end;
  2013.          elseif as_or = name then
  2014.             if type_bit.is_c_unsigned_ptr then
  2015.                fe_long_bit(rf8);
  2016.             else
  2017.                cpp.put_character('(');
  2018.                cpp.put_target_as_target;
  2019.                cpp.put_character(')');
  2020.                cpp.put_character('|');
  2021.                cpp.put_character('(');
  2022.                cpp.put_ith_argument(1);
  2023.                cpp.put_character(')');
  2024.             end;
  2025.          elseif as_not = name then
  2026.             if type_bit.is_c_unsigned_ptr then
  2027.                fe_long_bit(rf8);
  2028.             else
  2029.                type_bit.mapping_cast
  2030.                cpp.put_character('~');
  2031.                cpp.put_character('(');
  2032.                cpp.put_target_as_target;
  2033.                cpp.put_character(')');
  2034.             end;
  2035.          elseif as_and = name then
  2036.             if type_bit.is_c_unsigned_ptr then
  2037.                fe_long_bit(rf8);
  2038.             else
  2039.                cpp.put_character('(');
  2040.                cpp.put_target_as_target;
  2041.                cpp.put_character(')');
  2042.                cpp.put_character('&');
  2043.                cpp.put_character('(');
  2044.                cpp.put_ith_argument(1);
  2045.                cpp.put_character(')');
  2046.             end;
  2047.          elseif as_last = name then
  2048.             if type_bit.is_c_unsigned_ptr then
  2049.                rf8.default_mapping_function;
  2050.             elseif boost then
  2051.                cpp.put_string("(((unsigned int)(");
  2052.                cpp.put_target_as_target;
  2053.                cpp.put_string("))&1)");
  2054.             else
  2055.                rf8.default_mapping_function;
  2056.             end;
  2057.          elseif as_to_character = name then
  2058.             cpp.put_target_as_value;
  2059.          elseif as_to_integer = name then
  2060.             cpp.put_target_as_value;
  2061.          end;
  2062.       end;
  2063.  
  2064.    c_define_function_bit(rf8: RUN_FEATURE_8; name: STRING) is
  2065.       local
  2066.          type_bit: TYPE_BIT;
  2067.          no_check: BOOLEAN;
  2068.       do
  2069.          type_bit ?= rf8.current_type;
  2070.          no_check := run_control.no_check;
  2071.          if as_count = name then
  2072.          elseif as_item = name then
  2073.             if type_bit.is_c_unsigned_ptr then
  2074.                body.copy("{int ib=(CHAR_BIT*sizeof(int));%N%
  2075.                          %int widx=((");
  2076.                type_bit.unsigned_padding.append_in(body);
  2077.                body.append("+a1-1)/ib);%N%
  2078.                            %unsigned int word=*(((unsigned int*)C)+widx);%N%
  2079.                            %int bidx=((a1-1+");
  2080.                type_bit.unsigned_padding.append_in(body);
  2081.                body.append(")%%ib)+1;%N%
  2082.                            %int shift=ib-bidx;%N%
  2083.                            %R=((word>>shift)&1);%N}%N");
  2084.                rf8.c_define_with_body(body);
  2085.             elseif no_check then
  2086.                body.copy("R=(((unsigned int)C>>(");
  2087.                type_bit.nb.append_in(body);
  2088.                body.append("-a1))&1);%N");
  2089.                rf8.c_define_with_body(body);
  2090.             end;
  2091.          elseif as_shift_left = name then
  2092.             if type_bit.is_c_unsigned_ptr then
  2093.                fe_long_bit(rf8);
  2094.             else
  2095.                rf8.c_define_with_body("R=(C<<a1);");
  2096.             end;
  2097.          elseif as_shift_right = name then
  2098.             if type_bit.is_c_unsigned_ptr then
  2099.                fe_long_bit(rf8);
  2100.             else
  2101.                rf8.c_define_with_body("R=(C>>a1);");
  2102.             end;
  2103.          elseif as_last = name then
  2104.             if type_bit.is_c_unsigned_ptr then
  2105.                body.copy("{int ib=(CHAR_BIT*sizeof(int));%N%
  2106.                          %int widx=((");
  2107.                type_bit.unsigned_padding.append_in(body);
  2108.                body.extend('+');
  2109.                (type_bit.nb - 1).append_in(body);
  2110.                body.append(")/ib);%N%
  2111.                            %unsigned int word=*(((unsigned int*)C)+widx);%N%
  2112.                            %int bidx=((");
  2113.                (type_bit.nb - 1).append_in(body);
  2114.                body.extend('+');
  2115.                type_bit.unsigned_padding.append_in(body);
  2116.                body.append(")%%ib)+1;%N%
  2117.                            %int shift=ib-bidx;%N%
  2118.                            %R=((word>>shift)&1);%N}%N");
  2119.                rf8.c_define_with_body(body);
  2120.             elseif no_check then
  2121.                body.copy("R=(((unsigned int)C)&1);%N");
  2122.                rf8.c_define_with_body(body);
  2123.             end;
  2124.          end;
  2125.       end;
  2126.  
  2127. feature {NONE}
  2128.  
  2129.    unknown_native(rf: RUN_FEATURE) is
  2130.       do
  2131.          eh.add_position(rf.start_position);
  2132.          fatal_error("Unknown native feature.");
  2133.       end;
  2134.  
  2135. end -- NATIVE_SMALL_EIFFEL
  2136.  
  2137.  
  2138.